package com.example.springcloud.consumer.student.cloudclient.fallback;

import com.example.springcloud.common.entity.ResponseResult;
import com.example.springcloud.common.entity.Student;
import com.example.springcloud.consumer.student.cloudclient.StudentFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component
@Slf4j
public class ProviderStudentFallback implements StudentFeignClient {
    private ResponseResult<?> fallback(String method, Object... objects) {
        log.info(method + " 请求参数: " + Arrays.toString(objects));
        return new ResponseResult<>(500, "服务故障", null);
    }

    @Override
    public ResponseResult<?> addStudent(Student student) {
        return fallback("addStudent", student);
    }

    @Override
    public ResponseResult<?> findStudent(int id) {
        return fallback("findStudent", id);
    }

    @Override
    public ResponseResult<?> findAllStudents() {
        return fallback("findAllStudents");
    }

    @Override
    public ResponseResult<?> deleteStudent(int id) {
        return fallback("deleteStudent", id);
    }

    @Override
    public ResponseResult<?> updateStudent(Student student) {
        return fallback("updateStudent", student);
    }

    @Override
    public ResponseResult<?> getOk() {
        return fallback("getOk");
    }

    @Override
    public ResponseResult<?> getOut() {
        return fallback("getOut");
    }
}
